package com.miaomiao.domain.system;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.miaomiao.common.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;


@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserVo{
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    private String userName;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private String password;

    private String realName;

    private String email;

    private String telephone;

    private String stuId;

    private List<Role> roles;

    public UserVo(User user, List<Role> roles){
        this.userId = user.getUserId();
        this.userName = user.getUserName();
        this.password = null; // 密码不返回
        this.realName = user.getRealName();
        this.email = user.getEmail();
        this.telephone = user.getTelephone();
        this.stuId = user.getStuId();
        this.roles = roles;
    }
}
